{layout name="common/basic" /}
<script>
    function showHint(str) {


        var xmlhttp;
        if (str.length == 0) {
            document.getElementById("txtHint").innerHTML = "请输入手机号";
            return;
        }

        if (str.length != 11) {
            document.getElementById("txtHint").innerHTML = "手机号格式有误";
            return;
        }

        // var phone = str.length;
        //   if(!(/^1[34578]\d{9}$/.test(phone))){
        //       document.getElementById("txtHint").innerHTML="手机号格式有误";
        //       return false;
        //   }
        if (window.XMLHttpRequest) {
            // IE7+, Firefox, Chrome, Opera, Safari 浏览器执行代码
            xmlhttp = new XMLHttpRequest();
        } else {
            // IE6, IE5 浏览器执行代码
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
        }
        xmlhttp.onreadystatechange = function () {
            if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
                document.getElementById("txtHint").innerHTML = '开始读取数据';
                document.getElementById("txtHint").innerHTML = xmlhttp.responseText;
            }
            if (xmlhttp.status > 200) {

                document.getElementById("txtHint").innerHTML = "请稍后再试 错误：" + xmlhttp.readyState + " 状态" + xmlhttp.status;

            }
        }
        xmlhttp.open("POST", "{$Think.server.script_name}/index/api/sms/s/" + str, true);
        xmlhttp.send();
        showtime(120);
    }
</script>

<script type="text/javascript">

    function showtime(t) {
        document.getElementById("sms").disabled = true;
        for (i = 1; i <= t; i++) {
            window.setTimeout("update_p(" + i + "," + t + ")", i * 1000);
        }

    }

    function update_p(num, t) {
        if (num == t) {
            document.getElementById("sms").innerHTML = "重新发送";
            document.getElementById("sms").disabled = false;
        } else {
            printnr = t - num;
            document.getElementById("sms").innerHTML = " (" + printnr + ")s";
        }
    }
</script>

<div class="row">
<div class="col-md-6">
    <div class="card card-primary">
        <div class="card-header">
            <h3 class="card-title">密码重置</h3>
        </div>
        <!-- /.card-header -->
        <!-- form start -->
        <form role="form" method="post" action="">
            <div class="card-body">
                <div class="form-group">
                    <label for="exampleInputEmail1">手机号</label>
                    <input type="text" id="tel182" name="phone" class="form-control"   placeholder="输入已注册手机号">
                </div>
                <div class="input-group mb-3">
                    <input type="text" class="form-control" name="rand" placeholder="请输入验证码">
                    <div class="input-group-append">
                    <span class="input-group-text" id="sms" onclick="showHint(document.getElementById('tel182').value)">
                        <i class="fas fa-envelope" style="padding-right: 5px"></i>获取验证码</span>
                    </div>
                </div>
                <div class="form-group">
                    <label for="exampleInputPassword1">新密码</label>
                    <input type="password"name="password" class="form-control" placeholder="输入新密码">
                </div>


            </div>
            <!-- /.card-body -->

            <div class="card-footer">
                <button type="submit" class="btn btn-primary">提交</button>
                <span id="txtHint" style="color: orangered;padding-left: 5px">{$warning}</span>
            </div>

        </form>
    </div>
          </div>

 
</div>




